package main

import (
	"github.com/gin-gonic/gin"
	"strings"
)

func main() {
	r := gin.Default()
	r.GET("/ip", func(c *gin.Context) {
		addr := c.Request.RemoteAddr
		ip := strings.Split(addr, ":")[0]
		c.JSON(200, gin.H{
			"ip": ip,
		})
	})
	_ = r.Run() // listen and serve on 0.0.0.0:8080
}
